{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">订单管理</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"
               data-auth-add="{:$auth->check('member2.order/add')}"
               data-auth-edit="{:$auth->check('member2.order/edit')}"
               data-auth-delete="{:$auth->check('member2.order/del')}"
        ></table>
    </div>
</div>

<script type="text/html" id="barTool">

    <a onclick="wk.layer_show('订单详细','{:url('detail')}?id={{d.id}}',300,true)"
       class="layui-btn layui-bg-cyan layui-btn-xs" title="订单详情">订单详细</a>
    <!--    <a onclick="wk.layer_show('商品详细','{:url('goods_detail')}?id={{d.id}}',300,true)"-->
    <!--       class="layui-btn layui-bg-cyan layui-btn-xs" title="订单详情">商品详细</a>-->

    <!--    <a data-open='{:url("detail")}?id={{ d.id }}' class="layui-btn layui-btn-xs layui-btn-normal {:$auth->check('member2.order/detail')?'':'layui-hide'}" title="服务站审核">订单详情</a>&ndash;&gt;-->
    <!--    <a onclick="wk.layer_show('编辑用户','{:url('edit_vip')}?id={{d.u_id}}')" class="layui-btn layui-btn-xs" title="编辑"><i class="fa fa-pencil"></i></a>-->

    <!--    <a href="javascript:;" onclick="wk.confirm('{{d.u_id}}','{:url('del_vip')}')" class="layui-btn layui-btn-danger layui-btn-xs" title="删除"><i class="fa fa-trash-o"></i></a>-->

</script>
<!--<script type="text/html" id="barTool">-->
<!--    <a data-open='{:url("detail")}?id={{ d.id }}' class="layui-btn layui-btn-xs layui-btn-normal {:$auth->check('member2.order/detail')?'':'layui-hide'}" title="服务站审核">订单详情</a>-->
<!--&lt;!&ndash;    <a data-open='{:url("edit")}?id={{ d.id }}' class="layui-btn layui-btn-xs {:$auth->check('auth.rule/edit')?'':'layui-hide'}" title="编辑"><i class='iconfont icon-brush_fill'></i></a>&ndash;&gt;-->
<!--&lt;!&ndash;    <a href='{:url("del")}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('auth.rule/del')?'':'layui-hide'}"><i class='iconfont icon-trash_fill'></i></a>&ndash;&gt;-->
<!--</script>-->

<!--操作模板-->

{/block}
{block name="script"}
<script>
    layui.use(['yznTable', 'table'], function () {
        var table = layui.yznTable;
        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: "{:url('add')}",
            edit_url: "{:url('edit')}",
            delete_url: "{:url('del')}",
        };
        table.render({
            elem: '#currentTable',
            init: init,
            autoWidth: true,
            toolbar: ['refresh',],
            url: '{:url("index")}',
            cols: [
                [
                    //price 订单金额
                    //status '0待支付 1待发货 2待收货 配送中 3已完成 4已取消 5售后',
                    //pay_type '支付方式 1水卡支付 2直接支付',
                    // `pay_status` tinyint(2) DEFAULT '0' COMMENT '支付状态 0未支付1已支付',
                    //`create_time` int(16) DEFAULT NULL COMMENT '创建时间',
                    //`pay_time` int(16) DEFAULT NULL COMMENT '支付时间',
                    //`dispatch_time` int(16) DEFAULT NULL COMMENT '派单时间',
                    //`deliver_time` int(16) DEFAULT NULL COMMENT '送达时间',
                    {field: 'id', width: 50, title: 'ID'},
                    {field: 'order_no', Width: 110, title: '订单编号'},
                    {field: 'nickname', Width: 150, title: '下单用户', search: false},
                    {field: 'member_id', Width: 150, title: '下单用户ID', hide: true},
                    {field: 'business_name', Width: 150, title: '所属服务站', search: false},
                    {field: 'business_id', Width: 150, title: '所属服务站ID', hide: true},
                    {field: 'price', Width: 120, title: '订单金额', search: false},
                    {
                        field: 'status', Width: 60, title: '订单状态', templet: function (d) {
                            switch (d.status) {
                                case 0:
                                    return '<span style="color: red">待支付</span>';
                                    break;
                                case 1:
                                    return '<span style="color: red">待发货</span>';
                                    break;
                                case 2:
                                    return '<span style="color: red">待收货</span>';
                                    break;
                                case 3:
                                    return '<span style="color: green">已完成</span>';
                                    break;
                                case 4:
                                    return '<span>已取消</span>';
                                    break;
                                case 5:
                                    return '<span style="color: orange">售后</span>';
                                    break;
                                case 6:
                                    return '<span style="color: orange">已退款</span>';
                                    break;
                                default:
                                    return '<span style="color: purple">未知</span>';
                            }
                        }, selectList: {0: '待支付', 1: '待发货', 2: '待收货', 3: '已完成', 4: '已取消', 5: '售后'},
                    },
                    {
                        field: 'pay_status', Width: 90, title: '支付状态', templet: function (d) {
                            if (d.pay_status == 0) {
                                return '<span style="color: red">未支付</span>';
                            } else {
                                return '<span style="color: green">已支付</span>';
                            }
                        }, selectList: {0: '未支付', 1: '已支付'},
                    },
                    {
                        field: 'pay_type', Width: 90, align: 'center', title: '支付方式', templet: function (d) {
                            if (d.pay_type == 1) {
                                return '<span style="color: black;font-weight: bold">水票支付</span>';
                            } else if (d.pay_type == 2) {
                                return '<span style="color: green;font-weight: bold">微信支付</span>';
                            } else {
                                return '<span style="color: black font-weight: bold">——————</span>';
                            }
                        }, selectList: {1: '水票支付', 2: '微信支付'},
                    },
                    {field: 'create_time', Width: 150, title: '下单时间', search: 'range'},
                    {field: 'pay_time', Width: 60, title: '支付时间', search: 'range'},
                    {fixed: 'right', align: 'center', Width: 50, title: '操作', toolbar: '#barTool'}//delete'
                ]
            ],
            page: {}
        });
        table.bindevent();
    });
</script>
{/block}